Page({
  data:{
    id:'',
    encryptedData:'',
    houseInfo:'',
    url:'',
    validTime:''
  },
  onLoad(e){
    this.setData({id:e.id})
    this.getDetail()
  },
  // 保存图片
  onSave(){
    wx.downloadFile({
      url: this.data.url,
      success:(res)=>{
        wx.saveImageToPhotosAlbum({
          filePath: res.tempFilePath,
          success:()=>{
            wx.showToast({
              title: '成功',
            })
          }
        })
      }
    })
  },
  async getDetail(){
    const res = await wx.http({url:`/visitor/${this.data.id}`})
    // console.log(res);
    this.setData({...res.data})
  },
  // 倒计时
  timeEnd(){
    this.setData({validTime:0})
  },
  onShareAppMessage() {
    return {
      title: '交出买路财',
      path: '/visitor_pkg/pages/passport/index?encryptedData='+this.data.encryptedData,
      imageUrl: 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
})
